<template>
	<view>
		<view class="gui-padding gui-border-b" v-for="(user,index) in userlist" @click="login(user)">
			{{user.label}}
		</view>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				userlist:[]
			}
		},
		onLoad() {
			this.getData();
		},
		methods: {
			getData(){
				let self=this;
				this.$boya.NGet("/app/testUser",null,function(res){
					self.userlist=res.data;
				})
			},
			login(user){
				console.log(user);
				this.$boya.NPost("/app/testUser_login",{"user_name":user.value},function(res){
					console.log(res);
					uni.setStorageSync("Bearer",res.data.Bearer);
					uni.setStorageSync("userInfo",res.data.user);
					uni.setStorageSync("userName",user.value);
					uni.reLaunch({
						url:"/pages/switchPages/main"
					})
					
				})
			}
		}
	}
</script>

<style>

</style>
